<%-- 
    Document   : HomeContent
    Created on : Aug 28, 2011, 12:22:19 PM
    Author     : NHAnh - nhanh@fit.hcmus.edu.vn
--%>

<%@page import="model.pojo.DanhMuc"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <form name="frmTimKiem" action="BookListController" method="get">
                <table width="100%">
                    <tr>
                        <td align="center">TÌM KIẾM SÁCH</td>
                    </tr>
                    <tr>
                        <td align="center"><label for="tenSach"></label>
                            <input name="tenSach" type="text" id="tenSach" 
                                   <%                                       
                                       if (request.getParameter("tenSach") != null) {
                                   %>
                                   value="<%=request.getParameter("tenSach")%>"
                                   <%}%>
                                   /></td>
                    </tr>
                    <tr>
                        <td align="center"><label for="danhMuc"></label>
                            <select name="danhMuc" id="danhMuc">
                                <option value="All">--Chọn danh mục--</option> 
                                <%                                    
                                    ArrayList<DanhMuc> ds = (ArrayList<DanhMuc>) request.getAttribute("DanhMucs");
                                    for (int i = 0; i < ds.size(); i++) {
                                        DanhMuc dm = ds.get(i);
                                        
                                %>
                                <option value="<%=dm.getMaDanhMuc()%>" 
                                        <%                                            
                                            if (request.getParameter("danhMuc") != null) {
                                                String danhMuc = request.getParameter("danhMuc");
                                                
                                                if (danhMuc.equals(dm.getMaDanhMuc())) {
                                                    
                                        %>
                                        selected="selected"
                                        <%}
                                            }%>
                                        ><%=dm.getTenDanhMuc()%></option>
                                <%}%>
                            </select></td>
                    </tr>
                    <tr>
                        <td align="center">
                            <input type="submit" name="timKiem" id="timKiem" value="Tìm kiếm" />
                            <input type="hidden" name="Action" value="Search" />
                        </td>
                    </tr>
                </table>
            </form>
        </td>
    </tr>
    <tr>
        <td>
            <table width="100%" border="1">
                <tr>
                    <td align="center">DANH MỤC</td>
                </tr>
                <%                    
                    for (int i = 0; i < ds.size(); i++) {
                        DanhMuc dm = ds.get(i);
                %>
                <tr>
                    <td align="center"><a href="BookListController?Action=View&MaDanhMuc=<%=dm.getMaDanhMuc()%>"><%=dm.getTenDanhMuc()%></a></td>
                </tr>
                <%}%>
            </table>
        </td>
    </tr>
</table>